<template>
  <div>
    <h3>医疗服务历史</h3>
    <el-table :data="medicalServiceRecords">
      <el-table-column prop="medicalserviceid" label="医疗服务ID"></el-table-column>
      <el-table-column prop="servicedate" label="服务日期"></el-table-column>
      <el-table-column prop="insuredpersonid" label="参保人ID"></el-table-column>
      <el-table-column prop="medicalinstitutionid" label="医保机构ID"></el-table-column>
      <el-table-column prop="diagnosis" label="诊断结果"></el-table-column>
      <el-table-column prop="treatment" label="治疗方案"></el-table-column>
      <el-table-column prop="totalcost" label="总费用"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  data() {
    return {
      medicalServiceRecords: []


      // 用于存储获取到的医疗服务历史记录
    };
  },
  mounted() {
    console.log('通过 $route.params 获取的用户名:', this.$route.params.username);
    this.fetchMedicalServiceRecords();
  },
  methods: {
    fetchMedicalServiceRecords() {
      // 在这里实现获取医疗服务记录的请求
      axios.get(`http://localhost:8081/medicalService/getByInsuredPersonId/${this.$route.params.username}`)
          // 假设API路径为/api/medical-service-history
        .then(response => {
          this.medicalServiceRecords = response.data;
        })
        .catch(error => {
          console.error("Error fetching medical service records:", error);
        });
    }
  }
};
</script>

<style scoped>
.el-table {
  width: 100%;
}
</style>
